var e = require;
var t = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0}), (o.ObjectTool = void 0);
var n = (function () {
    function e() {}
    return (
        (e.prototype.start = function () {}),
        (e.createNode = function (e, t, o) {
            void 0 === o && (o = new cc.Vec2(0, 0));
            var n = new cc.Node(e);
            return null != t ? t.addChild(n) : cc.director.getScene().addChild(n), n;
        }),
        (e.createNodeWithParent = function (e, t, o, n) {
            return (
                void 0 === n && (n = new cc.Vec2(0, 0)),
                ((t = cc.instantiate(t)).name = e),
                null != o ? o.addChild(t) : cc.director.getScene().addChild(t),
                t.setPosition(n),
                t
            );
        }),
        (e.createSpriteNode = function (e, t, o) {
            var n = new cc.Node(e);
            return (
                (n.addComponent(cc.Sprite).spriteFrame = t),
                null != o ? o.addChild(n) : cc.director.getScene().addChild(n),
                n
            );
        }),
        (e.instanceWithPrefab = function (e, t, o, n) {
            void 0 === n && (n = new cc.Vec2(0, 0));
            var a = cc.instantiate(t);
            return (
                null == a && console.error("the _prefab " + e + ",_prefab name:" + t + " is null!!!"),
                (a.name = e),
                null != o ? o.addChild(a) : cc.director.getScene().addChild(a),
                a.setPosition(n),
                a
            );
        }),
        (e.instanceWithNode = function (e, t, o, n) {
            void 0 === n && (n = new cc.Vec2(0, 0));
            var a = cc.instantiate(t);
            return (
                null == a && console.error("the _prefab " + e + ",_prefab name:" + t + " is null!!!"),
                (a.name = e),
                null != o ? o.addChild(a) : cc.director.getScene().addChild(a),
                a.setPosition(n),
                a
            );
        }),
        (e.GlobalFindObj = function (e) {
            var t = cc.find("Canvas/" + e);
            return null == t && console.error("！！！the find node is null------------------------"), t;
        }),
        (e.FindObjWithParent = function (e, t) {
            var o = cc.find(e, t);
            return null == o && console.error("！！！the find " + e + " node is null------------------------"), o;
        }),
        (e.GetCanvas = function () {
            return cc.find("Canvas");
        }),
        (e.GetMainCamera = function () {
            return cc.find("Canvas/Main Camera");
        }),
        (e.setScale = function (e, t, o, n) {
            void 0 === o && (o = 0),
                void 0 === n && (n = 0),
                0 != o && 0 != n && (e.setScale(1), (e.width = o), (e.height = n));
            var a;
            (a = t.getRect().width > t.getRect().height ? e.width / t.getRect().width : e.height / t.getRect().height),
                (e.width = t.getRect().width),
                (e.height = t.getRect().height),
                e.setScale(a);
        }),
        (e.SetRoleScale = function (e, t, o, n) {
            void 0 === o && (o = 0),
                void 0 === n && (n = 0),
                0 != o && 0 != n && (e.setScale(1), (e.width = o), (e.height = n));
            var a = 0;
            if (
                ((a =
                    t.getRect().width > t.getRect().height
                        ? e.width / t.getRect().width
                        : e.height / t.getRect().height),
                e.width >= t.getRect().width && e.height >= t.getRect().height)
            )
                return (a = 1), (e.width = t.getRect().width), void (e.height = t.getRect().height);
            (e.width = t.getRect().width), (e.height = t.getRect().height), e.setScale(a);
        }),
        (e.createText = function (e, t, o, n) {
            void 0 === n && (n = new cc.Vec2(0, 0));
            var a = new cc.Node(e);
            a.setPosition(n),
                a.addComponent(cc.Label),
                (a.getComponent(cc.Label).string = o),
                (a.getComponent(cc.Label).fontSize = 20),
                (a.getComponent(cc.Label).lineHeight = 23),
                (a.color = new cc.Color(93, 236, 60));
            var i = cc.moveBy(0.5, cc.v2(0, 40));
            return (
                a.runAction(
                    cc.sequence(
                        i,
                        cc.callFunc(
                            function () {
                                a.destroy();
                            }.bind(this)
                        )
                    )
                ),
                null != t ? t.addChild(a) : cc.director.getScene().addChild(a),
                a
            );
        }),
        (e.finish = function () {
            console.log("动作完成----------");
        }),
        (e.forEachObject = function (e) {
            for (var t in e)
                if (e.hasOwnProperty(t)) {
                    var o = e[t];
                    console.log("obj key:" + t + ",value :" + o);
                }
        }),
        (e.parseKeyValue = function (e) {
            for (var t = (e = e.replace("{", "").replace("}", "")).split(","), o = [], n = 0; n < t.length; n++) {
                var a = t[n];
                o.push([a.split(":")[0], a.split(":")[1]]);
            }
            return o;
        }),
        e
    );
})();
o.ObjectTool = n;
